import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class UploadHelpPage extends StatefulWidget {
  const UploadHelpPage({Key? key}) : super(key: key);

  @override
  State<UploadHelpPage> createState() => _UploadHelpPageState();
}

class _UploadHelpPageState extends State<UploadHelpPage> {
  String _markdownContent = '';
  bool _isLoading = true;

  @override
  void initState() {
    super.initState();
    _loadMarkdownContent();
  }

  Future<void> _loadMarkdownContent() async {
    try {
      final content = await rootBundle.loadString('lib/docs/upload_guide.md');
      if (mounted) {
        setState(() {
          _markdownContent = content;
          _isLoading = false;
        });
      }
    } catch (e) {
      if (mounted) {
        setState(() {
          _markdownContent = '加载帮助文档失败: $e';
          _isLoading = false;
        });
      }
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('上传功能帮助')),
      body:
          _isLoading
              ? const Center(child: CircularProgressIndicator())
              : SingleChildScrollView(
                padding: const EdgeInsets.all(16),
                child: Text(
                  _markdownContent,
                  style: Theme.of(context).textTheme.bodyMedium,
                ),
              ),
    );
  }
}
